home *** CD-ROM | disk | FTP | other *** search
/ Software Vault: The Gold Collection / Software Vault - The Gold Collection (American Databankers) (1993).ISO / cdr47 / wasm223.zip / MULPLX2.ASM < prev    next >
Assembly Source File  |  1993-05-04  |  5KB  |  153 lines

  1. ;****************************************;
  2. ; WASM Multiplex Support, Transient Code ;
  3. ; By Eric Tauck                          ;
  4. ;                                        ;
  5. ; Defines:                               ;
  6. ;                                        ;
  7. ;   PlxChn  chain (install) interrupt    ;
  8. ;   PlxQue  query resident TSR           ;
  9. ;   PlxChk  check if can unhook          ;
  10. ;   PlxRel  release (unhook) interrupt   ;
  11. ;                                        ;
  12. ; Requires:                              ;
  13. ;                                        ;
  14. ;   INTR2.ASM                            ;
  15. ;   MULPLX1.ASM                          ;
  16. ;                                        ;
  17. ; This code is the transient portion of  ;
  18. ; the multiplex support.  These routines ;
  19. ; initialize this code and data in       ;
  20. ; MULPLX2.ASM. This file should included ;
  21. ; within the transient portion of the    ;
  22. ; TSR, while MULPLX1.ASM should be       ;
  23. ; included in the resident portion.      ;
  24. ;****************************************;
  25.  
  26. ; RES_OFF and RES_ID must be EQUated by the user.  RES_ID is a 16 bit value
  27. ; that should be unique for all programs using MULPLX1.ASM and MULPLX2.ASM.
  28. ; RES_OFF is the byte offset to subtract from all memory references if the
  29. ; TSR is shifted to a lower memory location.  If the TSR is not shifted,
  30. ; RES_OFF should be set to zero.
  31.  
  32.         jmps    _mulplex2_end
  33.  
  34. ;================================================
  35. ; Chain interrupt.
  36. ;
  37. ; In: AX= multiplex number; CX= version number;
  38. ;     DX= handler (can be zero if none); 
  39. ;
  40. ; Note: If the resident code is relocated, the
  41. ; relocation should be performed BEFORE this
  42. ; routine is called (i.e. the variables are
  43. ; assumed to be at their relocated addresses).
  44.  
  45. PlxChn  PROC    NEAR
  46.  
  47. ;--- define data
  48.  
  49.         mov     _PlxNum - RES_OFF, ax   ;save number
  50.         mov     _PlxVer - RES_OFF, cx   ;save version
  51.         or      dx, dx                  ;check if handler defined
  52.         jz      _plxch1
  53.         sub     dx, RES_OFF             ;adjust
  54.         mov     _PlxHan - RES_OFF, dx   ;save handler
  55.  
  56. ;--- hook interrupts
  57.  
  58. _plxch1 mov     al, 2FH
  59.         mov     bx, OFFSET PlxOld - RES_OFF
  60.         mov     cx, OFFSET _PlxNew - RES_OFF
  61.         call    IntChn                  ;chain interrupt
  62.         ret
  63.         ENDP
  64.  
  65. ;================================================
  66. ; Query resident TSR.
  67. ;
  68. ; In: AX= multiplex number.
  69. ;
  70. ; Out: DX= resident segment (zero if not
  71. ;      resident or another TSR hooked); CX=
  72. ;      resident version; CY= set another TSR
  73. ;      using multiplex number.
  74.  
  75. PlxQue  PROC    NEAR
  76.         push    di
  77.         push    si
  78.         push    bp
  79.         push    ds
  80.         push    es
  81.         sub     bx, bx                  ;zero id
  82.         mov     cx, bx                  ;zero version
  83.         mov     dx, bx                  ;zero segment
  84.         push    ax
  85.         int     2FH                     ;query
  86.         pop     di
  87.         cmp     di, ax                  ;check if anyone hooked
  88.         je      _plxqu2
  89.         cmp     bx, RES_ID              ;verify owner
  90.         jne     _plxqu3
  91.         clc
  92. _plxqu1 pop     es
  93.         pop     ds
  94.         pop     bp
  95.         pop     si
  96.         pop     di
  97.         ret
  98.  
  99. ;--- not resident
  100.  
  101. _plxqu2 or      cx, cx                  ;verify unchanged
  102.         jnz     _plxqu3
  103.         or      bx, bx                  ;verify unchanged
  104.         jnz     _plxqu3
  105.         or      dx, dx                  ;verify unchanged
  106.         jz      _plxqu1
  107.  
  108. ;--- other program using multiplex number
  109.  
  110. _plxqu3 sub     dx, dx                  ;zero segment
  111.         stc
  112.         jmps    _plxqu1
  113.         ENDP
  114.  
  115. ;================================================
  116. ; Check if interrupt has been changed.
  117. ;
  118. ; In: AX= multiplex number.
  119. ;
  120. ; Out: ZF= set if unchanged.
  121.  
  122. PlxChk  PROC    NEAR
  123.         call    PlxQue                  ;resident query
  124.         or      dx, dx                  ;check if segment returned
  125.         jz      _plxck1
  126.  
  127.         mov     al, 2FH                 ;interrupt
  128.         mov     cx, OFFSET _PlxNew - RES_OFF ;handler offset
  129.         call    IntChk                  ;check interrupt 2F
  130.         ret
  131.  
  132. _plxck1 dec     dx                      ;clear ZF
  133.         ret
  134.         ENDP
  135.  
  136. ;================================================
  137. ; Release interrupt.
  138. ;
  139. ; In: AX= multiplex number.
  140.  
  141. PlxRel  PROC    NEAR
  142.         call    PlxQue                  ;get resident segment
  143.         push    ds
  144.         mov     ds, dx
  145.         mov     al, 2FH                 ;interrupt
  146.         mov     bx, OFFSET PlxOld-RES_OFF ;variable
  147.         call    IntRel                  ;release interrupt 21
  148.         pop     ds
  149.         ret
  150.         ENDP
  151.  
  152. _mulplex2_end
  153.